﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XNADota.ContentPipeline.Data;
using Microsoft.Xna.Framework;
using System.Diagnostics;
using XNADota.Input;

namespace XNADota.UI
{
    public class Panel : UIElement, IInputHandler
    {
        protected Button[] _Buttons;
        protected PanelSetting _Setting;

        public Panel(Game game, PanelSetting setting)
            : base(game)
        {
            _Setting = setting;

            Debug.Assert(setting.ButtonPosition.Length == setting.ButtonSize.Length);
            _Buttons = new Button[setting.ButtonPosition.Length];

            for (int i = 0; i < _Buttons.Length; i++)
            {
                Vector2 position = setting.ButtonPosition[i];
                Vector2 size = setting.ButtonSize[i];

                _Buttons[i] = new Button(game, (int)position.X, (int)position.Y, (int)size.X, (int)size.Y);

                _Buttons[i].AddLabel("UIs//cmd//BTN_CR_ATTACKING", _Setting.X, _Setting.Y, 0);
                _Buttons[i].AddLabel("UIs//cmd//DISBTN_CR_ATTACKING", _Setting.X, _Setting.Y, 1);

                (_Game as XNADota).InputManager.Add(_Buttons[i]);
            }
        }

        public void Update(GameTime gameTime)
        {
            for (int i = 0; i < _Buttons.Length; i++)
                _Buttons[i].Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            for (int i = 0; i < _Buttons.Length; i++)
                _Buttons[i].Draw(gameTime);

            base.Draw(gameTime);
        }

        public virtual void ProcessInput(GameTime gameTime, InputState inputState)
        {
            throw new NotImplementedException("this method is not implmented.");
        }
    }
}
